﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Agr.CQRS.Domain.Repository
{
    class Cache
    {
        private Dictionary<string, CacheItem> cacheItems = new Dictionary<string, CacheItem>();

        public void AddItem(CacheItem ci)
        {
            if (!cacheItems.ContainsKey(ci.Key))
                cacheItems.Add(ci.Key, ci);
        }
        public CacheItem GetItem(string key)
        {
            if (!cacheItems.ContainsKey(key))
                return null;
            return cacheItems[key];
        }

        public void RemoveItem(string key)
        {
            if (cacheItems.ContainsKey(key))
                cacheItems.Remove(key);
        }

        public bool HasItem(string key)
        {
            return cacheItems.ContainsKey(key);
        }
    }
}
